<?php

class OKHelper
{
	protected $site;
	protected $page;
	
	public $data;
	
	public function __construct( Site &$site )
	{
		$this->site	= &$site;
		$this->page = &$site->page;
	}
	
	public function menu_set_state( $name, $state = "active" )
	{
		$name = str_replace(" ", "_", $name);
		$name = str_replace("/", "_", $name);
		
		$this->site->page->setVar( "mnu_act_".$name, $state );
	}
	
	public function control_base()
	{
		header("Content-type: text/html; charset=utf-8");
		$this->page->template = "base/index.tpl";
		$this->page->add_css("base.css");
		$this->page->add_css("control.css");
		
		$this->page->add_js("jquery-2.0.0.js");
		$this->page->add_js("base.js");
		
		$this->page->header("control/header.tpl");
		$this->page->footer("control/footer.tpl");
		
		$this->page->setVar("server_time", date("H:i (P)", time()));
	}
	
	
	public function get_data()
	{
		$this->site->db->driver_connect();
		$this->site->db->select("*", "admins")->where("`id`='".$_SESSION['uid']."'")->result();
		$arr = $this->site->db->fetch_array();
		if ( $arr )
		{
			$this->data = $arr;
		}
		else
		{
			header("Location: /admin/");
			return;
		}
	}
}


